#!/bin/bash
export R_HOME=@R_HOME@
export RCC_R_INCLUDE_PATH=@RCC_R_INCLUDE_PATH@
BINDIR=`dirname $0`
CMD="$BINDIR/rcc.bin"
if [[ ${LD_LIBRARY_PATH} ]]
then
    export LD_LIBRARY_PATH=@R_LIB_PATH@:@RCC_LIB_PATH@:${LD_LIBRARY_PATH}
else
    export LD_LIBRARY_PATH=@R_LIB_PATH@:@RCC_LIB_PATH@
fi
# hackery to run rcc under gdb using rcc's arguments
if [[ "${PRERUN}" == "gdb" ]]
then
    TMPFILE=`mktemp /tmp/rcc.XXXXXX`
    echo "set args $*" > ${TMPFILE}
    CMD="${PRERUN} ${CMD} -x ${TMPFILE}"
else
    CMD="${PRERUN} ${CMD} $*"
fi
exec ${CMD}
